import store from "../store"

let countReducer=(state=33,action)=>{
  switch (action.type) {
    case 'add':
     return state + action.payload
    case 'sub':
     return state - action.payload
    case 'chen':
     return state * action.payload
    case 'chu':
      return state / action.payload
    default:
      return state
  }
}

export default countReducer

export let addAction=(payload)=>{
  return {
    type: 'add',
    payload
  }
}

export let allAsyncActiong=(type,payload)=>{
  return ()=>{
    setTimeout(()=>{
      store.dispatch({type,payload})
    },1000)
  }
}

export let subAction=payload=>({
  type:'sub',
  payload
})

export let allAction=(type,payload)=>({
  type,
  payload
})